package com.boot.hospital.score.core.service.impl;

import com.boot.hospital.score.core.service.ScoreService;

import com.boot.hospital.score.dao.entity.Cadre;
import com.boot.hospital.score.dao.entity.CadreAndScore;
import com.boot.hospital.score.dao.entity.Score;
import com.boot.hospital.score.dao.mapper.CadreMapper;
import com.boot.hospital.score.dao.mapper.ScoreMapper;
import com.boot.hospital.score.dao.mapper.UserMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;

@Service
@Transactional(rollbackFor = Exception.class)
public class ScoreServiceImpl implements ScoreService {

    @Resource
    private ScoreMapper scoreMapper;
    @Resource
    private CadreMapper cadreMapper;

    @Override
    public List<Score> selectAll() {
        return scoreMapper.selectAll();
    }

    @Override
    public int insert(Score score) {
        return scoreMapper.insert(score);
    }

    @Override
    public Score selectByReviewIdAndExpertId(Map<String, Object> params) {
        return scoreMapper.selectByReviewIdAndExpertId(params);
    }

    @Override
    public CadreAndScore getScoresAndCadres(Map<String, Object> params) {

        Score score = scoreMapper.selectByReviewIdAndExpertId(params);
        Integer cadresId = Integer.valueOf(score.getCadresId());
        Cadre cadre = cadreMapper.selectByCadreId(cadresId);
        CadreAndScore cadreAndScore = new CadreAndScore(cadre, score);

        return cadreAndScore;


    }

    @Override
    public int deleteScoresByReviewIds(List<Integer> reviewIds) {
        return deleteScoresByReviewIds(reviewIds);
    }


}
